package com.yang.webhook.modules.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yang.webhook.common.utils.AjaxUtil;

import net.sf.json.JSONObject;

/** 
* @author 刘超  作者 E-mail:liuchao@huiwtech.com
* @date 创建时间：2017年7月19日 上午11:24:26 
* @version 1.0 
* @parameter  
* @since  
* @return  
*/
@Controller
@RequestMapping(value="/WisLog")
public class WisLogHandlers extends BaseControl{
	@RequestMapping(value = "/list.do")
	public void hello(HttpServletRequest request,HttpServletResponse response) throws Exception {
		 AjaxUtil.ajaxJSONResponse(response,this.wisLogService.list());
	}
	
	
	
	/**
	 * 记录系统日志
	 * @param request  permisGpId
	 * @throws Exception
	 * @author 刘超
	 */
	@RequestMapping(value = "/recordinfLog.do")
	public void recordinfLog(HttpServletRequest request,HttpServletResponse response) throws Exception {
		StringBuilder builder = new StringBuilder();
		String aux = "";
		JSONObject json = null;
		while ((aux = request.getReader().readLine()) != null) {
			builder.append(aux);
		}
		String text = builder.toString();
			json = JSONObject.fromObject(text);
	    	String logSysIdentify=json.get("logSysIdentify").toString();
	    	String logSysPersonId=json.get("logSysPersonId").toString();
	    	String logSysRecordingtime=json.get("logSysRecordingtime").toString();
	    	String logSysOperationdesc=json.get("logSysOperationdesc").toString();
	    	String logSysSystemdesc=json.get("logSysSystemdesc").toString();
/*
	         System.out.println(request.getRequestURL());//得到请求URL地址
	         System.out.println(request.getRequestURI());//得到请求的资源
	         System.out.println(request.getQueryString());
	         System.out.println(request.getRemoteAddr());//得到来访者IP
	         System.out.println(request.getRemoteHost());
	         System.out.println(request.getRemotePort());//得到请求的资源
	         System.out.println(request.getMethod());//得到请求的资源
*/	 
	    	String logSysurl=request.getRequestURL().toString();
		AjaxUtil.ajaxJSONResponse(response,this.wisLogService.recordinfLog(logSysIdentify,logSysPersonId,logSysRecordingtime,logSysOperationdesc,logSysSystemdesc,logSysurl));
	}
	
}